package com.unbox.common.annotation.validation;
import com.unbox.common.annotation.*;
import com.unbox.common.util.UnBoxUtils;
import com.unbox.common.util.UnboxLog;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;

@Data
public class ValidationMaps {

    // 存储对应的注解以及对应验证类
    private Map<Class, ValidationCompare> annotationValidationMap = new HashMap<>();

    // 获取国际化日志输出
    UnboxLog unboxLog = new UnBoxUtils.LocaleMessageLog(ValidationMaps.class);

    public ValidationMaps init() {
        annotationValidationMap.put(Max.class, new ValidMax());
        annotationValidationMap.put(Min.class, new ValidMin());
        annotationValidationMap.put(NotNull.class,new ValidNotNull());
        annotationValidationMap.put(NotNumber.class, new ValidNotNumber());
        annotationValidationMap.put(Size.class, new ValidSize());
        unboxLog.info("validation.info.msg");
        return this;
    }

    /**
     * 获取对应的验证方法
     * @param cls
     * @return
     */
    public ValidationCompare getValidataion(Class cls) {
        return annotationValidationMap.get(cls);
    }
}
